
package com.xbongbong.admin.model.impl;

import com.xbongbong.admin.domain.dao.VideoDao;
import com.xbongbong.admin.domain.entity.VideoEntity;
import com.xbongbong.admin.model.VideoModel;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Objects;


/**
* @author autoGen
* @time 2019-09-18 13:56:16
*/
@Service("videoModel")
public class VideoModelImpl implements VideoModel {

	@Resource
	private VideoDao dao;
	@Override
	public Integer insert(VideoEntity entity){
		long now = DateUtil.getInt();
    	entity.setAddTime(now);
		entity.setUpdateTime(now);

		return dao.insert(entity);
	}

	@Override
	public void updateBatch(List<VideoEntity> list) {
		dao.updateBatch(list);
	}

	@Override
	public Integer update(VideoEntity entity){
		long now = DateUtil.getInt();
		entity.setUpdateTime(now);

		return dao.update(entity);
	}

	@Override
	public Integer save(VideoEntity entity){

		if(entity.getId() == null || Objects.equals(0L, entity.getId())) {
			return insert(entity);
		}
		return update(entity);
	}

	@Override
	public void insertBatch(List<VideoEntity> entityList) {
    	dao.insertBatch(entityList);
    }

	@Override
	public Integer deleteByKey( Long key){
		return dao.deleteByKey(key);
	}

	@Override
	public VideoEntity getByKey( Long key){
		return dao.getByKey(key);
	}

	@Override
	public List<VideoEntity> findEntitys(Map<String ,Object>  param){
		return dao.findEntitys(param);
	}

    @Override
	public Integer getEntitysCount(Map<String ,Object>  param){
		return dao.getEntitysCount(param);
	}

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }


}

